package edu.gatech.cs2340.teamrocket.control.networking.impl.messagehandler;

import edu.gatech.cs2340.teamrocket.control.networking.dialog.Dialog;
import edu.gatech.cs2340.teamrocket.control.networking.node.Node;
import edu.gatech.cs2340.teamrocket.control.networking.impl.VTNetworkingInterface;
import edu.gatech.cs2340.teamrocket.control.networking.impl.message.ChatMessage;
import edu.gatech.cs2340.teamrocket.control.networking.message.Message;
import edu.gatech.cs2340.teamrocket.control.networking.messagehandler.MessageHandler;
import edu.gatech.cs2340.teamrocket.view.networking.ChatDisplay;

/**
 * Default Client message handler for the Victory Trail.
 *
 * @author Joe Tacheron
 */
public class VTClientMessageHandler implements MessageHandler {

    private ChatDisplay display;

    @Override
    public void handleMessage(Node endpoint, Dialog dialog, Message message) {

        VTNetworkingInterface net = VTNetworkingInterface.getInstance();

        if(message instanceof ChatMessage){
            ChatMessage m = (ChatMessage)message;
            display.recieveChatMessage(m.getName() + ": " + m.getComment());
        }
    }

    public void setChatDisplay(ChatDisplay display){
        this.display = display;
    }
}
